package command {
	import business.ProductDelegate;

	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.view.ViewLocator;

	import event.ProductEvent;

	import model.ProductModel;

	import mx.rpc.IResponder;

	import view.ProductViewHelper;

	public class AddProductCommand implements IResponder, ICommand {
		private var productModel:ProductModel=ProductModel.getInstance();

		public function AddProductCommand() {
		}

		public function execute(e:CairngormEvent):void {
			var delegate:ProductDelegate=new ProductDelegate(this);
			delegate.addProduct((e as ProductEvent).product);
		}

		public function result(data:Object):void {
			if (data) {
				productModel.ac.addItem(data);
				productModel.msg="Successful.";
				var productViewerHelper:ProductViewHelper=ViewLocator.getInstance().getViewHelper("productView") as ProductViewHelper;
				productViewerHelper.showMsg();
			}
		}

		public function fault(info:Object):void {
			trace(info);
		}



	}
}